package main

import (
	"crypto/sha256"
	"fmt"
)

func main() {
	c1 := sha256.Sum256([]byte{'x'});
	c2 := sha256.Sum256([]byte{'X'});
	fmt.Printf("%x\n%x\n", c1, c2);
	numTrue := 0;
	numFalse := 0;
	var c3 [32]byte;
	//fmt.Printf("%x", c1);
	for i := 0; i < 32; i++ {
		c3[i] = c1[i] & c2[i];
		numTrue += deal(c3[i]);
	}
	numFalse = 8*32 - numTrue;
	fmt.Printf("%x\n", c3);
	fmt.Printf("相同bit个数：%d，不同bit个数：%d\n", numTrue, numFalse);

	//

}

func deal(a byte) int {
	var num int;
	var i uint;
	for i = 0; i < 8; i++ {
		num += deal2(a, i);
	}
	return num;
}

func deal2(a byte, i uint) int {
	var b uint8 = 1;
	return int(a & (b << i) / (b << i));
}

// 数字转换成二进制后有多少个1
//func PopCount(x uint64) int {
//return int(pc[byte(x>>(0*8))] +
//	pc[byte(x>>(1*8))] +
//	pc[byte(x>>(2*8))] +
//	pc[byte(x>>(3*8))] +
//	pc[byte(x>>(4*8))] +
//	pc[byte(x>>(5*8))] +
//	pc[byte(x>>(6*8))] +
//	pc[byte(x>>(7*8))]);
//}
